Skip to content

Conversation

petyaslavova
Copy link
Collaborator

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Fixing errors reported by mypy.

@petyaslavova petyaslavova added the breakingchange API or Breaking Change label Jun 3, 2025
@petyaslavova petyaslavova marked this pull request as ready for review October 8, 2025 06:12
@petyaslavova petyaslavova changed the title Fixing errors reported by mypy. Fixing errors reported by mypy in search module files - query.py, commands.py and aggregation.py. Oct 8, 2025
@petyaslavova petyaslavova requested a review from Copilot October 8, 2025 06:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes mypy type checking errors in the Redis search module by improving type annotations and correcting type inconsistencies across query.py, commands.py, and aggregation.py files.

  • Added missing type imports and improved type annotations for better static type checking
  • Fixed parameter type definitions to use proper Optional syntax instead of Union with None
  • Corrected return type annotations and variable type declarations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
redis/commands/search/query.py Enhanced type annotations, fixed return types, and improved parameter type definitions
redis/commands/search/commands.py Replaced Union with None syntax with proper Optional type annotations
redis/commands/search/aggregation.py Added comprehensive type annotations and fixed method signatures

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

self._scorer: Optional[str] = None
self._filters: List = list()
self._ids: Optional[List[str]] = None
self._ids: Optional[Tuple[str]] = None
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type annotation Optional[Tuple[str]] creates a tuple with exactly one string element. This should likely be Optional[Tuple[str, ...]] for a variable-length tuple or Optional[List[str]] to maintain the original list behavior.

Suggested change
self._ids: Optional[Tuple[str]] = None
self._ids: Optional[Tuple[str, ...]] = None

Copilot uses AI. Check for mistakes.

self._args = args
self._field = None
self._alias = None
self._args: tuple[str, ...] = args
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Tuple[str, ...] instead of tuple[str, ...] for consistency with other type annotations in the codebase that use the typing module imports.

Copilot uses AI. Check for mistakes.


@property
def args(self) -> List[str]:
def args(self) -> tuple[str, ...]:
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Tuple[str, ...] instead of tuple[str, ...] for consistency with other type annotations in the codebase that use the typing module imports.

Copilot uses AI. Check for mistakes.

Comment on lines +52 to +54
else:
# Chop off initial '@'
alias = self._field[1:]
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added else clause is unnecessary since the previous if block already handles the case when self._field is falsy. The original logic was correct - if self._field exists, process it; otherwise, the ValueError would have been raised.

Suggested change
else:
# Chop off initial '@'
alias = self._field[1:]
# Chop off initial '@'
alias = self._field[1:]

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakingchange API or Breaking Change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant